package com.aim.analysis.questionnaire;

import com.aim.util.extractors.ValueExtractor;

/**
 * User: Avraham Shvartzon
 * Date: 6/18/14
 */
public abstract class QValueExtractor<V> extends ValueExtractor<QuestionnaireRecord, V> {

    protected QValueExtractor(String name) {
        super(name);
    }

    public final static QValueExtractor<String> partitionKey = new QValueExtractor<String>("partitionKey"){
        @Override
        public String getValue(QuestionnaireRecord q) {
            return q.partitionKey;
        }
    };
   public final static QValueExtractor<String> gender = new QValueExtractor<String>("gender"){
        @Override
        public String getValue(QuestionnaireRecord q) {
            return q.gender == null ? "N/A" : q.gender;
        }
    };

    public final static  QValueExtractor<Integer> female = new QValueExtractor<Integer>("female") {
        @Override
        public Integer getValue(QuestionnaireRecord q) {
            return (q.gender != null && q.gender.equalsIgnoreCase("female")) ? 1 : 0;
        }
    };

    public final static  QValueExtractor<Integer> male = new QValueExtractor<Integer>("male") {
        @Override
        public Integer getValue(QuestionnaireRecord q) {
            return (q.gender != null && q.gender.equalsIgnoreCase("male")) ? 1 : 0;
        }
    };

    public final static  QValueExtractor<Integer> age = new QValueExtractor<Integer>("age") {
        @Override
        public Integer getValue(QuestionnaireRecord q) {
            if (q.age == 0) {
                return 30;
            }
            return q.age > 100 ? 2014 - q.age : q.age;
        }
    };
    public final static  QValueExtractor<Integer> enjoyGame = new QValueExtractor<Integer>("enjoyGame") {
        @Override
        public Integer getValue(QuestionnaireRecord q) {
            return q.enjoyGame;
        }
    };
    public final static  QValueExtractor<Integer> performanceSelfAssessment= new QValueExtractor<Integer>("performanceSelfAssessment") {
        @Override
        public Integer getValue(QuestionnaireRecord q) {
            return q.performanceSelfAssessment;
        }
    };;
    public final static  QValueExtractor<String> alertFrequency = new QValueExtractor<String>("alertFrequency"){
        @Override
        public String getValue(QuestionnaireRecord q) {
            return q.alertFrequency;
        }
    };

    public final static  QValueExtractor<Integer> alertFrequency_int = new QValueExtractor<Integer>("noTrustSystem"){
        @Override
        public Integer getValue(QuestionnaireRecord q) {
            return q.alertFrequency.equals("noTrustSystem") ? 1 : 0;
        }
    };
    public final static QValueExtractor<String> setFrequency = new QValueExtractor<String>("setFrequency"){
        @Override
        public String getValue(QuestionnaireRecord q) {
            return q.setFrequency;
        }
    };;

    public final static QValueExtractor<Integer> setFrequency_int = new QValueExtractor<Integer>("setFrequency"){
        @Override
        public Integer getValue(QuestionnaireRecord q) {
            return q.setFrequency.contains("Yes") ? 1 : 0;
        }
    };

    public final static  QValueExtractor<Integer>  secondsInAdvanceForAlert= new QValueExtractor<Integer>("secondsInAdvanceForAlert") {
        @Override
        public Integer getValue(QuestionnaireRecord q) {
            return q.secondsInAdvanceForAlert;
        }
    };;
    public final static  QValueExtractor<Integer>  maintenanceAlertsHelpful= new QValueExtractor<Integer>("maintenanceAlertsHelpful") {
        @Override
        public Integer getValue(QuestionnaireRecord q) {
            return q.maintenanceAlertsHelpful;
        }
    };;
    public final static QValueExtractor<String> gameStrategyDesc = new QValueExtractor<String>("gameStrategyDesc"){
        @Override
        public String getValue(QuestionnaireRecord q) {
            return q.gameStrategyDesc;
        }
    };;
    public final static  QValueExtractor<Integer>  takeRisks= new QValueExtractor<Integer>("takeRisks") {
        @Override
        public Integer getValue(QuestionnaireRecord q) {
            return q.takeRisks;
        }
    };;
    public final static QValueExtractor<String> bugsOccured = new QValueExtractor<String>("bugsOccured"){
        @Override
        public String getValue(QuestionnaireRecord q) {
            return q.bugsOccured;
        }
    };;
    public final static QValueExtractor<String> bugDescriptionIfExist = new QValueExtractor<String>("bugDescriptionIfExist"){
        @Override
        public String getValue(QuestionnaireRecord q) {
            return q.bugDescriptionIfExist;
        }
    };;
    public final static QValueExtractor<String> freeText = new QValueExtractor<String>("freeText"){
        @Override
        public String getValue(QuestionnaireRecord q) {
            return q.freeText;
        }
    };;

}
